import {request} from '@umijs/max';

export interface StateType {
  status?: 'ok' | 'error';
  currentAuthority?: 'user' | 'guest' | 'admin';
}

export interface UserRegisterParams {
  headImg?: string;
  identifier: string;
  credential: string;
  confirm: string;
  username: string;
  code: string;
}

export async function fakeRegister(params: UserRegisterParams) {
  return request('/account-service/api/v1/account/register', {
    method: 'POST',
    data: params,
    getResponse: true,
  });
}

export async function sendCode(params: any) {
  return request('/account-service/api/v1/notify/send_code', {
    method: 'POST',
    data: params,
  });
}

export async function getWechatQr(params?: any, options?: { [key: string]: any }) {
  return request<{
    code: number
    data: any
    msg: string
  }>('/account-service/api/v1/wechat/login', {
    params,
    ...(options || {}),
  })
}


export async function checkScan(params?: any, options?: { [key: string]: any }) {
  return request<{
    code: number
    data: any
    msg: string
  }>('/account-service/api/v1/wechat/check_scan', {
    params,
    ...(options || {}),
  })
}
